#include"com.h"
int main()
{
  key_t key = ftok(PATHNAME,PROJ_ID);
  if(key<0)
  {
    perror("ftok failed\n");
    return 1;
  }

  int shm = shmget(key,SIZE,IPC_CREAT|IPC_EXCL|0666);//创建新的
  if(shm<0)
  {
    perror("shmget failed\n");
    return 2;
  }

  printf("attach begin!\n");
  char* mem = shmat(shm, NULL,0);//关联共享内存
  if(mem==(void*)-1)
  {
    perror("shmat failed!!\n");
      return 3;
  }
  printf("attach end!!\n");
  while(1)
  {
   printf("client# %s\n",mem);
   sleep(1);
  }
  //去关联
  shmdt(mem);
  shmctl(shm,IPC_RMID,NULL);// delete
  return 0;
}

